<html>
<head><meta charset="utf-8"><title>issue 9307 · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html">issue 9307</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211152731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211152731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211152731">(Sep 24 2020 at 16:02)</a>:</h4>
<p>Hi! I think I could give type checking (some of the) lang items a go - issue <a href="https://github.com/rust-lang/rust/issues/9307">#9307</a>.</p>
<p>What I have in mind is checking Struct targets by adding the ability to create a string signature (maybe by using Encodable?) for VariantData and compare that to what's defined for lang items that target Structs. Does anybody have a strong opinion about this approach?</p>



<a name="211153308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211153308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211153308">(Sep 24 2020 at 16:06)</a>:</h4>
<p>I'm not sure I understand the approach. Can you give an example?</p>



<a name="211153716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211153716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211153716">(Sep 24 2020 at 16:09)</a>:</h4>
<p>Let's take OwnedBox for example. Instead of defining it's target as simply Target::Struct, I'd change it to Target::Struct("Box(T)") or something like that, and I'd make it possible for the struct's hir ItemKind to construct this signature string</p>



<a name="211155401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211155401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211155401">(Sep 24 2020 at 16:23)</a>:</h4>
<p>In essence, serialize the relevant piece of data in the hir, and compare it against a signature defined for the lang item's Target. I'm not sure, though, if I'm allowed to allocate strings</p>



<a name="211155784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211155784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211155784">(Sep 24 2020 at 16:26)</a>:</h4>
<p>Hmm, since I only need to compare a known string against something dynamic, in theory I can do this without allocation, but that would require refactoring how the actual_target is passed around</p>



<a name="211155789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211155789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211155789">(Sep 24 2020 at 16:26)</a>:</h4>
<p>I don't know if that's possible at all</p>



<a name="211155947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211155947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211155947">(Sep 24 2020 at 16:27)</a>:</h4>
<p>I mean, you could check the list of generic params and the name of the thing... but at that point you're just duplicating all the info in a second place</p>



<a name="211155985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211155985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211155985">(Sep 24 2020 at 16:27)</a>:</h4>
<p>ok... I guess any approach will do that</p>



<a name="211156134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211156134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211156134">(Sep 24 2020 at 16:28)</a>:</h4>
<p>I'd definitely choose something more structured than a string format. we do have symbols, so you could check the name against a symbol</p>



<a name="211156225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211156225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211156225">(Sep 24 2020 at 16:29)</a>:</h4>
<p>Though the name isn't very meaningful for the compiler, even though it's nice if the names used in the compiler match up with those from libstd</p>



<a name="211156430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211156430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211156430">(Sep 24 2020 at 16:30)</a>:</h4>
<p>I'm not sure how that would look, I'm a bit concerned about making this look nice as part of the current lang item table, that's why I'm thinking about strings. Naming the thing would help with providing an approximate signature in the error message more simple IMO.</p>



<a name="211156489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211156489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211156489">(Sep 24 2020 at 16:30)</a>:</h4>
<p>But I guess that can be omitted as well</p>



<a name="211156731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211156731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211156731">(Sep 24 2020 at 16:32)</a>:</h4>
<p>there's already a name in the table, maybe we just reuse that and then sync it up?</p>



<a name="211156794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211156794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211156794">(Sep 24 2020 at 16:33)</a>:</h4>
<p>(likely some lang item names are differently from the name of the item itself)</p>



<a name="211156975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211156975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211156975">(Sep 24 2020 at 16:34)</a>:</h4>
<p>I think we can also reuse the actual name given by the user. The signature itself doesn't need to contain it, if the name is not important.</p>



<a name="211157011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/issue%209307/near/211157011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/issue.209307.html#211157011">(Sep 24 2020 at 16:34)</a>:</h4>
<p>But this is rather theoretical at this point <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>